RStorage = game.ReplicatedStorage;
local sharedLibs = RStorage.SharedLibs;
local oo = require(sharedLibs.BaseLib)

Binaryheap = require(script.Parent.binaryHeap);

--- PriorityQueue可以通过BinaryHeap实现。
--- 这里对对BinaryHeap简单Wrap下，提供符合当前框架和命名
--- 习惯的接口，把它改造成一个PriorityQueue
--- (binaryHeap源代码风格特别别留，代码阅读很困难)
local cls = {}

--- lt is compare function (less than)
function cls.new(lt)
	local heap = Binaryheap.minUnique(lt);
	
	--- params: void
	heap.Peek = heap.peek;	
	--- params: priority, item
	heap.Put = heap.insert;
	--- Return values: item, priority
	heap.Pop = heap.pop;
	--- params: item, priority	
	heap.Update = heap.update;
	--- params: void
	heap.GetSize = heap.size;
	--- params: item
	heap.Remove = heap.remove;
	
	heap.IsEmpty = function(self)
		return self:GetSize() == 0;
	end
	
	return heap;
end
 
return cls;
